package com.pgeneral.user.management.controller;/**
 * @author 龙
 * @create 2020/7/2 14:32
 */

import com.pgeneral.user.management.config.ResultBean;
import com.pgeneral.user.management.entity.SopScopeData;
import com.pgeneral.user.management.service.impl.SopScopeDataServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *@ClassName SopScopeDataController
 *@Description 权限的增删改查接口
 *@Author JL
 *@Date 2020/7/2 14:32
 *@version 1.0
 **/

@Slf4j
@RestController
@RequestMapping("/sopScopeData")
public class SopScopeDataController {

    @Autowired
    private SopScopeDataServiceImpl sopScopeDataService;

    /**
     * 添加权限信息
     *
     * @param sopScopeDatas
     * @return
     */
    @RequestMapping(value = "/saveInfo", method = RequestMethod.POST)
    public ResultBean insertSopScopeDataTable(@RequestBody List<SopScopeData> sopScopeDatas) {
        log.info("调用权限save方法，方法参数为：{}",sopScopeDatas);
        int result = sopScopeDataService.insert(sopScopeDatas);
        return ResultBean.InsertSuccessResult(result);

    }

    /**
     * 权限查询
     *
     * @param sopScopeData
     * @return
     */
    @RequestMapping(value = "/getInfo", method = RequestMethod.POST)
    public ResultBean getSopScopeDataTable(@RequestBody SopScopeData sopScopeData) {
        log.info("调用权限get方法，方法参数为：{}",sopScopeData);
        List<SopScopeData> sopScopeDatas = sopScopeDataService.getSopScopeDataTable(sopScopeData);
        return ResultBean.Success(sopScopeDatas);

    }

    /**
     * 权限更新
     *
     * @param sopScopeDatas
     * @return
     */
    @RequestMapping(value = "/updateInfo", method = RequestMethod.POST)
    public ResultBean updateSopScopeDataTable(@RequestBody List<SopScopeData> sopScopeDatas) {
        log.info("调用权限update方法，方法参数为：{}",sopScopeDatas);
        int result = sopScopeDataService.updateSopScopeDataTable(sopScopeDatas);
        return ResultBean.InsertSuccessResult(result);

    }

    /**
     * 权限删除
     *
     * @param ids
     * @return
     */
    @RequestMapping(value = "/deleteInfo", method = RequestMethod.POST)
    public ResultBean deleteSopScopeDataTable(@RequestBody List<String> ids) {
        log.info("调用权限delete方法，方法参数为：{}",ids);
        int result = sopScopeDataService.updateIsDeletefromSopScopeDataTable(ids);
        return ResultBean.InsertSuccessResult(result);
    }
}
